#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,a[45][45]={0},x,y,c=0;
    scanf("%d",&n);
    x=0;y=0;
    c=a[x][y]=1;
    while (c<n*(n+1)/2)
    {
        while (x+1<n&&!a[x+1][y])a[++x][y]=++c;
        while (y+1<n&&!a[x][y+1])a[x][++y]=++c;
        while (y-1>=0&&x-1>=0&&!a[x-1][y-1])a[--x][--y]=++c;
    }
    for(x=0;x<n;x++)
	{
		for(y=0;y<n;y++)
		{
			if(a[x][y])
				printf("%5d",a[x][y]);
		}
			printf("\n");
	}
    return 0;
}
